package com.jz.netthings.engine.service.impl;

import com.jy.faceValidate.utils.FaceValidateUtils;
import com.jz.netthings.engine.service.ClientService;
import com.jz.netthings.netty.protocol.bean.ZxdcMsgPacket;
import org.slf4j.Logger;

import java.util.HashMap;

public class EngineSupport {

    /**
     * 人脸认证
     * @param donorId
     * @param face
     * @param seq
     * @param cmd
     * @param clientService
     * @param logger
     * @return
     */
    public static ZxdcMsgPacket faceRecognition(String donorId,byte[] face,String seq,String cmd, ClientService clientService,Logger logger){
        ZxdcMsgPacket targetPacket = new ZxdcMsgPacket();

        logger.info("开始进行【" + donorId + "】的人脸认证...");
        String[] path = clientService.getImgsPath( donorId, face);

        if (path[0] != null && path[1] != null) {
            float result = FaceValidateUtils.validateImg(path[0], path[1]);

            targetPacket.setSeq(seq);
            targetPacket.setCmd("response");
            targetPacket.setResponseFromCmd(cmd);
            HashMap<String, Object> values = new HashMap<String, Object>();
            values.put("num", result);
            targetPacket.setValues(values);
        }
        return targetPacket;
    }
}
